<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>jspline</title>
    <link rel="stylesheet" type="text/css" href="csound.css" />
    <meta name="generator" content="DocBook XSL Stylesheets V1.78.1" />
    <link rel="home" href="index.html" title="The Canonical Csound Reference Manual" />
    <link rel="up" href="OpcodesTop.html" title="Orchestra Opcodes and Operators" />
    <link rel="prev" href="joystick.html" title="joystick" />
    <link rel="next" href="opk.html" title="k" />
  </head>
  <body>
    <div class="navheader">
      <table width="100%" summary="Navigation header">
        <tr>
          <th colspan="3" align="center">jspline</th>
        </tr>
        <tr>
          <td width="20%" align="left"><a accesskey="p" href="joystick.html">Prev</a> </td>
          <th width="60%" align="center">Orchestra Opcodes and Operators</th>
          <td width="20%" align="right"> <a accesskey="n" href="opk.html">Next</a></td>
        </tr>
      </table>
      <hr />
    </div>
    <div class="refentry">
      <a id="jspline"></a>
      <div class="titlepage"></div>
      <a id="IndexJspline" class="indexterm"></a>
      <div class="refnamediv">
        <h2>
          <span class="refentrytitle">jspline</span>
        </h2>
        <p>jspline — 
      A jitter-spline generator.
          </p>
      </div>
      <div class="refsect1">
        <a id="idp118175696"></a>
        <h2>Description</h2>
        <p>
      A jitter-spline generator.
    </p>
      </div>
      <div class="refsect1">
        <a id="idp118176880"></a>
        <h2>Syntax</h2>
        <pre class="synopsis">ares <span class="command"><strong>jspline</strong></span> xamp, kcpsMin, kcpsMax</pre>
        <pre class="synopsis">kres <span class="command"><strong>jspline</strong></span> kamp, kcpsMin, kcpsMax</pre>
      </div>
      <div class="refsect1">
        <a id="idp118241808"></a>
        <h2>Performance</h2>
        <p>
      <span class="emphasis"><em>kres, ares</em></span> -- Output signal
    </p>
        <p>
      <span class="emphasis"><em>xamp</em></span> -- Amplitude factor
    </p>
        <p>
      <span class="emphasis"><em>kcpsMin, kcpsMax</em></span> -- Range of point-generation rate. Min and max limits are expressed in cps.
    </p>
        <p>
      <span class="emphasis"><em>jspline</em></span> (jitter-spline generator) generates a smooth curve based on random points generated at [<span class="emphasis"><em>cpsMin</em></span>, <span class="emphasis"><em>cpsMax</em></span>] rate.  This opcode is similar to <a class="link" href="randomi.html" title="randomi"><em class="citetitle">randomi</em></a> or <a class="link" href="randi.html" title="randi"><em class="citetitle">randi</em></a> or <a class="link" href="jitter.html" title="jitter"><em class="citetitle">jitter</em></a>, but segments are not straight lines, but cubic spline curves. Output value range is approximately &gt; -<span class="emphasis"><em>xamp</em></span> and &lt; <span class="emphasis"><em>xamp</em></span>. Actually, real range could be a bit greater, because of interpolating curves beetween each pair of random-points.
    </p>
        <p>
      At present time generated curves are quite smooth when <span class="emphasis"><em>cpsMin</em></span> is not too different from <span class="emphasis"><em>cpsMax</em></span>. When <span class="emphasis"><em>cpsMin</em></span>-<span class="emphasis"><em>cpsMax</em></span> interval is big, some little discontinuity could occurr, but it should not be a problem, in most cases. Maybe the algorithm will be improved in next versions.
    </p>
        <p>
      These opcodes are often better than <a class="link" href="jitter.html" title="jitter"><em class="citetitle">jitter</em></a> when user wants to <span class="quote">“<span class="quote">naturalize</span>”</span> or <span class="quote">“<span class="quote">analogize</span>”</span> digital sounds. They could be used also in algorithmic composition, to generate smooth random melodic lines when used together with <a class="link" href="samphold.html" title="samphold"><em class="citetitle">samphold</em></a> opcode.
    </p>
        <p>
      Note that the result is quite different from the one obtained by filtering white noise, and they allow the user to obtain a much more precise control.
    </p>
      </div>
      <div class="refsect1">
        <a id="idp118257296"></a>
        <h2>Examples</h2>
        <p>
      Here is an example of the jspline opcode. It uses the file <a class="ulink" href="examples/jspline.csd" target="_top"><em class="citetitle">jspline.csd</em></a>.
      </p>
        <div class="example">
          <a id="idp118259152"></a>
          <p class="title">
            <strong>Example 414. Example of the jspline opcode.</strong>
          </p>
          <div class="example-contents">
            <p>See the sections <a class="link" href="UsingRealTime.html" title="Real-Time Audio"><em class="citetitle">Real-time Audio</em></a> and <a class="link" href="CommandFlags.html" title="Csound command line"><em class="citetitle">Command Line Flags</em></a> for more information on using command line flags.</p>
            <pre class="programlisting">
<span class="csdtag">&lt;CsoundSynthesizer&gt;</span>
<span class="csdtag">&lt;CsOptions&gt;</span>
<span class="comment">; Select audio/midi flags here according to platform</span>
-odac     <span class="comment">;;;realtime audio out</span>
<span class="comment">;-iadc    ;;;uncomment -iadc if realtime audio input is needed too</span>
<span class="comment">; For Non-realtime ouput leave only the line below:</span>
<span class="comment">; -o jspline.wav -W ;;; for file output any platform</span>
<span class="csdtag">&lt;/CsOptions&gt;</span>
<span class="csdtag">&lt;CsInstruments&gt;</span>

<span class="ohdr">sr</span> <span class="op">=</span> 44100
<span class="ohdr">ksmps</span> <span class="op">=</span> 32
<span class="ohdr">nchnls</span> <span class="op">=</span> 2
<span class="ohdr">0dbfs</span>  <span class="op">=</span> 1

<span class="oblock">instr</span> 1

kamp    <span class="opc">init</span> p4
kcpsmin <span class="opc">init</span> 2
kcpsmax <span class="opc">init</span> 20

ksp  <span class="opc">jspline</span> kamp, kcpsmin, kcpsmax
aout <span class="opc">pluck</span> 1, 200<span class="op">+</span>ksp, 1000, 0, 1
aout <span class="opc">dcblock</span> aout	<span class="comment">;remove DC</span>
     <span class="opc">outs</span> aout, aout

<span class="oblock">endin</span>
<span class="csdtag">&lt;/CsInstruments&gt;</span>
<span class="csdtag">&lt;CsScore&gt;</span>

<span class="stamnt">i</span> 1 0 10 2	<span class="comment">;a bit jitter</span>
<span class="stamnt">i</span> 1 8 10 10	<span class="comment">;some more</span>
<span class="stamnt">i</span> 1 16 10 20	<span class="comment">;lots more</span>
<span class="stamnt">e</span>
<span class="csdtag">&lt;/CsScore&gt;</span>
<span class="csdtag">&lt;/CsoundSynthesizer&gt;</span>
</pre>
          </div>
        </div>
        <p><br class="example-break" />
    </p>
      </div>
      <div class="refsect1">
        <a id="idp118263440"></a>
        <h2>Credits</h2>
        <p>Author: Gabriel Maldonado</p>
        <p>New in Version 4.15</p>
      </div>
    </div>
    <div class="navfooter">
      <hr />
      <table width="100%" summary="Navigation footer">
        <tr>
          <td width="40%" align="left"><a accesskey="p" href="joystick.html">Prev</a> </td>
          <td width="20%" align="center">
            <a accesskey="u" href="OpcodesTop.html">Up</a>
          </td>
          <td width="40%" align="right"> <a accesskey="n" href="opk.html">Next</a></td>
        </tr>
        <tr>
          <td width="40%" align="left" valign="top">joystick </td>
          <td width="20%" align="center">
            <a accesskey="h" href="index.html">Home</a>
          </td>
          <td width="40%" align="right" valign="top"> k</td>
        </tr>
      </table>
    </div>
  </body>
</html>
